from rest_framework import serializers

from apps.goods.models import SKU
from apps.orders.models import OrderInfo, OrderGoods


class OrdersSimpleSer(serializers.ModelSerializer):
    class Meta:
        model=OrderInfo
        fields=['order_id','create_time']



class SKURealted(serializers.ModelSerializer):
    class Meta:
        model=SKU
        fields=['name','default_image']
class SkUGoodsRealted(serializers.ModelSerializer):
    sku=SKURealted(read_only=True)
    class Meta:
        model=OrderGoods
        fields=['count','price','sku']


class OrderSer(serializers.ModelSerializer):
    skus=SkUGoodsRealted(read_only=True,many=True)
    user=serializers.StringRelatedField(read_only=True)
    class Meta:
        model=OrderInfo
        fields="__all__"

